package com.apes.fn.tms.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fileserver.File;
import com.apes.framework.util.ApesConst;
import com.apes.hr.base.model.Job;
import com.apes.hr.base.model.WorkPost;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.party.model.Party;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 功能：司机管理
 *
 * @author Linwz
 * @create 2020-03-09 9:46
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Chauffeur.CONST_TABLE_NAME)
public class Chauffeur extends Model {
    public static final String CONST_TABLE_NAME = "tms_chauffeur";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "司机管理")
    @Comment("编码")
    private String id; //取人员档案的人员编码

    @Name
    @Column(name = "name", length = 30)
    @Comment("名称")
    private String name;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sex", referencedColumnName = "id")
    @Comment("性别")
    private Enumeration sex; //性别

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "work_post_id", referencedColumnName = "id")
    private WorkPost workPost; //职位

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "employee_state_id", referencedColumnName = "id")
    @Comment("员工状态")
    private Enumeration employeeState; //员工状态(employeeState)从申请面试开始  同旧框架 :(000088:在职;000089:已离职;000417:待入职)

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "work_state", referencedColumnName = "id")
//    @Comment("上班状态")
//    private Enumeration workState; //上班状态(onDutyState)

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "party_id", referencedColumnName = "id")
    @Comment("当事人编码")
    private Party party; //当事人编码

    @Column(name = "mobile_number", length = 16,unique = true)
    @Comment("手机号")
    private String mobileNumber; //手机号

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="vehicle_id",referencedColumnName="id")
    @Comment("车辆")
    private Vehicle vehicle;  //车辆

//    @File
//    @Lob
//    @Basic(fetch = FetchType.LAZY)
//    @Column(name = "driver_photo", columnDefinition = "CLOB")
//    private String driverPhoto;   // 驾驶证图片
//
//    @File
//    @Lob
//    @Basic(fetch = FetchType.LAZY)
//    @Column(name = "idCar_photo", columnDefinition = "CLOB")
//    private String idCarPhoto;   // 身份证图片

}
